package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.NursingPlanProjectDto;
import com.zzyl.entity.NursingPlanProject;
import com.zzyl.mapper.NursingPlanProjectMapper;
import com.zzyl.service.NursingPlanProjectService;
import com.zzyl.vo.NursingPlanProjectVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: NursingPlanProjectServiceImpl
 * @description:
 * @author: InnovatorX
 * @date: 2024/5/27 10:24
 * @Version: 1.0
 */
@Service
@Slf4j
public class NursingPlanProjectServiceImpl implements NursingPlanProjectService {
    @Autowired
    private NursingPlanProjectMapper nursingPlanProjectMapper;
    @Override
    public void saveBatch(List<NursingPlanProjectDto> projectDos, Long planId) {
        for (NursingPlanProjectDto projectDo : projectDos) {
            projectDo.setPlanId(planId);
        }
        List<NursingPlanProject> projectList = BeanUtil.copyToList(projectDos, NursingPlanProject.class);
        nursingPlanProjectMapper.saveBatch(projectList);
    }

    @Override
    public void deleteById(Long id) {
        nursingPlanProjectMapper.deleteById(id);
    }

    @Override
    public void updateByIdProject(List<NursingPlanProjectDto> projectPlans) {
        nursingPlanProjectMapper.updateByIdProject(projectPlans);
    }

    @Override
    public List<NursingPlanProjectVo> findByIdProject(Long id) {
        return nursingPlanProjectMapper.findByIdProject(id);
    }
}
